package com.esunny.online.service.impl;

import com.esunny.online.dao.ResourceTagDao;
import com.esunny.online.domain.entity.ResourceTag;
import com.esunny.online.service.ResourceTagService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: Bcc
 * @Date: 2020/9/8 15:23
 * @Description:
 * @modified By:
 * @version: $
 */

@Service
public class ResourceTagServiceImpl implements ResourceTagService {

    @Resource
    private ResourceTagDao resourceTagDao;

    /**
     * 添加记录
     * @param resourceTag 记录
     */
    @Override
    public void addResourceTag(ResourceTag resourceTag) {
        resourceTagDao.addResourceTag(resourceTag);
    }

    /**
     * 更新资源-标签删除状态
     * @param resourceTag 更新条件
     */
    @Override
    public void updateResourceTagIsDelete(ResourceTag resourceTag){
        List<ResourceTag> resourceTagByQuery = resourceTagDao.findResourceTag(resourceTag);
        for (ResourceTag resourceTag1: resourceTagByQuery) {
            resourceTag1.setIsdelete(!resourceTag1.getIsdelete());
            resourceTagDao.updateResourceTagIsDelete(resourceTag1);
        }
    }

    /**
     * 彻底删除记录
     * @param resourceTag 删除条件
     */
    @Override
    public void deleteResourceTag(ResourceTag resourceTag) {
        resourceTagDao.deleteResourceTag(resourceTag);
    }

    /**
     * 查找记录
     * @param resourceTag 查找条件
     * @return 返回记录列表
     */
    @Override
    public List<ResourceTag> findResourceTag(ResourceTag resourceTag) {
        return null;
    }
}
